﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Masterpages
{
    public partial class Default : System.Web.UI.Page
    {
        List<string> defaultLinks;

        protected void Page_Load(object sender, EventArgs e)
        {
            Master.link = "Pagetwo.aspx";
            Master.linkvalue = "Side to";
        }

        protected void gemLink(object sender, EventArgs e)
        {
            Master.AddLink(uiAdNewMenuItem.Text,uiAdNewMenuItem.Text);
            if (Session["Default"] == null)
            {
                defaultLinks = new List<string>();
            }
            else
            {
                defaultLinks = (List<string>)Session["Default"];
            }
            defaultLinks.Add(uiAdNewMenuItem.Text);
            Session["Default"] = defaultLinks;
        }

        protected void Page_Init(object sender, EventArgs e)
        {
            Master.MenuInitEvent += HandleMenuInit;                           
        }

        private void HandleMenuInit()
        {
            if (Session["Default"] != null)
            {
                defaultLinks = (List<string>)Session["Default"];
                foreach (string str in defaultLinks)
                {
                    Master.AddLink(str, str);
                }
            }
        }
    }
}